﻿<%@ Page Title="" Language="C#" MasterPageFile="~/EasyUI.Master" AutoEventWireup="true" CodeBehind="ListPch.aspx.cs" Inherits="jnxc.Web.nurseryRecord.ListPch" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script src="../Script/username.js"></script>
    <script src="../Script/datetime.js"></script>    
    <script type="text/javascript">
        $(function () {
            InitGird();
            InitTree();
        });
        function InitTree() {
            $('#pt').tree({
                url: '../addprevention/GetADD.ashx', //请求数据的页面               
                width: '100%', //宽度                
                lines: true,
                method: 'post',
                queryParams: { "action": "queryt" },
                onClick: function (node) {
                    if (node.text != "") {
                        if (node.type == "1") {
                            $('#idh').val(node.id);
                        }
                        else if (node.type == "2") {
                            $('#city').val(node.text);
                        }                        
                        $('#idstr').val(node.id);
                        $('#otype').val(node.type);
                        reloadgrid();
                    }
                },
                onLoadSuccess: function (node, param) {
                    $('#pt').tree("collapseAll");
                    var node = $('#pt').tree("getRoot");
                    if (node)
                    $('#pt').tree("expand", node.target);
                }
            });
        }
        //初始化表格
        function InitGird() {
            $('#tt').datagrid({
                title: '林业有害生物普查汇总表', //表格标题
                url: 'GetHz.ashx', //请求数据的页面
                sortName: 'mhid', //排序字段
                idField: '', //标识字段,主键
                iconCls: '', //标题左边的图标
                width: '100%', //宽度
                nowrap: false, //是否换行，True 就会把数据显示在一行里
                striped: true, //True 奇偶行使用不同背景色
                collapsible: false, //可折叠
                sortOrder: 'desc', //排序类型
                remoteSort: true, //定义是否从服务器给数据排序
                fitColumns: true,
                singleSelect: true,
                method: 'post',
                columns: [[
                    {
                        title: '省', width: 80, field: 'pname', rowspan: 2, align: 'center'
                    },
                    {
                        title: '市', width: 80, field: 'cname', rowspan: 2, align: 'center'
                    },
                    { title: '有害生物种类', width: 80, field: 'hname', rowspan: 2, align: 'center' },
                    { title: '拉丁学名', width: 80, field: 'ldxm', rowspan: 2, align: 'center' },
                     { title: '寄主植物', width: 80, field: 'plantname', rowspan: 2, align: 'center' },
                     { title: '危害部位', width: 80, field: 'harmParts', rowspan: 2, align: 'center' },
                     { title: '分布范围', width: 80, field: 'coname', rowspan: 2, align: 'center' },
                     { title: '发生范围', width: 80, field: 'coname', rowspan: 2, align: 'center' },
                    { title: '发生面积（万亩）', field: 'a', colspan: 4, align: 'center' },
                    {
                        title: '成灾面积', field: 'disarea', rowspan: 2, align: 'center'
                    },
                    { title: '备注', field: 'Remark', rowspan: 2, align: 'center' }],
                    [
                        { title: '轻', field: 'level1', align: 'center' },
                        { title: '中', field: 'level2', align: 'center' },
                        { title: '重', field: 'level3', align: 'center' },
                    {
                        title: '合计', field: 'level', formatter: function (value, row) {
                            return parseFloat(row.level1) + parseFloat(row.level2) + parseFloat(row.level3);
                        }, align: 'center'
                    }

                    ]
                ],
                toolbar: "#tab_toolbar",
                queryParams: { "action": "queryh" },
                pagination: true, //是否开启分页
                pageNumber: 1, //默认索引页
                pageSize: 20, //默认一页数据条数
                rownumbers: true //行号
            });

        }
        function showData() {
            if ($('#tt').datagrid('getRows').length > 0)
                $('#dlg').dialog('open').dialog('setTitle', '导出数据');
            else
                $.messager.alert("提示", "没有要导出的数据，请重新查询！", "info");

        }
        //添加    

        function getQueryParams(queryParams) {
            var StartTime = $("#StartTime").datebox("getValue");
            var EndTime = $("#EndTime").datebox("getValue");
            var idstr = $("#idstr").val();
            var idh = $("#idh").val();
            var otype = $("#otype").val();
            queryParams.StartTime = StartTime;
            queryParams.EndTime = EndTime;
            queryParams.idstr = idstr;
            queryParams.idh = idh;
            queryParams.otype = otype;
            return queryParams;

        }
        //增加查询参数，重新加载表格  
        function reloadgrid() {
            var queryParams = $('#tt').datagrid('options').queryParams;
            getQueryParams(queryParams);
            $('#tt').datagrid('options').queryParams = queryParams;
            $("#tt").datagrid('reload');

        }
        function outUser() {
            if ($("#fm").form('validate')) {
                var StartTime = $("#StartTime").datebox("getValue");
                var EndTime = $("#EndTime").datebox("getValue");
                var idstr = $("#idstr").val();
                var idh = $("#idh").val();
                var shr = $("#shr").val();
                var hzr = $("#hzr").val();
                var hzt = $("#hztime").datebox("getValue");
                var city = $("#city").val();
                var otype = $("#otype").val();
                var args = "st=" + StartTime + "&et=" + EndTime + "&id=" + idstr + "&shr=" + shr + "&hzr=" + hzr + "&hzt=" + hzt + "&city=" + city + "&otype=" + otype + "&idh=" + idh;
                DownLoad(args);
            }
            else {
                $.messager.alert("提示", "数据格式不对，请认真填写数据！", "info");
            }
        }
        function DownLoad(args) {
            var form = $("<form>");   //定义一个form表单
            form.attr('style', 'display:none');   //在form表单中添加查询参数
            form.attr('target', '');
            form.attr('method', 'post');
            form.attr('action', "GetHz.ashx?action=tth&" + args);

            $('body').append(form);  //将表单放置在web中 
            //form.append(input1);   //将查询参数控件提交到表单上
            form.submit();

        }

    </script>
    <style type="text/css">
        .fitem {
            width: 100%;
            
        }

            .fitem label {
                width:60px;
                line-height: 22px;
            }

            .fitem input {
                width: 120px;
            }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="easyui-layout" style="width: 100%; height: 100%;" id="mycon">
        <div region="west" split="true" title="区域检索" style="width: 180px; overflow: scroll" id="west">
            <ul id="pt"></ul>

        </div>
        <div region="center" style="background: #eee; overflow-y: hidden">
            <table id="tt">
            </table>
        </div>
        <div id="tab_toolbar" style="padding: 4px;">
            <table cellpadding="0" cellspacing="0" style="width: 100%">
                <tr>
                    <td style="padding-left: 2px">
                        <div>
                            时间从:  
           <input id="StartTime" class="easyui-datebox" style="width: 150px" />
                            到:  
           <input id="EndTime" class="easyui-datebox" style="width: 150px" />
                            

                            <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="reloadgrid()">查找</a>
                            <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save'" onclick="showData()">导出</a>
                        </div>
                    </td>
                </tr>
            </table>

        </div>
        <div id="dlg" class="easyui-dialog" style="width: 250px; height: 200px; overflow: auto; padding: 10px 20px"
            data-options="closed:true,buttons:'#dlg-buttons',shadow:false,resizable: true,maximizable:true">
            <form id="fm" method="post">
                <div class="fitem">
                    <label>汇总人：</label>
                    <input id="hzr" name="hzr" class="easyui-validatebox" data-options="required:true" />
                    <input name="idstr" id="idstr" type="hidden" />
                    <input name="idh" id="idh" type="hidden" />
                    <input name="city" id="city" type="hidden" />
                    <input name="st" id="st" type="hidden" />
                    <input name="et" id="et" type="hidden" />
                    <input name="otype" id="otype" type="hidden" />
                </div>
                <div class="fitem">
                    <label>审核人：</label>
                    <input id="shr" name="shr" class="easyui-validatebox" data-options="required:true" />
                </div>
                <div class="fitem">
                    <label>汇总时间：</label>
                    <input id="hztime" name="hztime" class="easyui-datebox" data-options="required:true" />
                </div>
            </form>
        </div>
        <div id="dlg-buttons">
            <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" onclick="outUser()">导出</a>
            <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="javascript:$('#dlg').dialog('close')">关闭</a>
        </div>
    </div>
</asp:Content>
